//
//  HowToCell.m
//  123
//
//  Created by Wang on 14/11/19.
//  Copyright (c) 2014年 Wang. All rights reserved.
//

#import "HowToCell.h"

@implementation HowToCell

- (void)dealloc
{
    [_titleLabel release];
    [_detailLabel release];
    [_image release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        
        self.titleLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        [_titleLabel setTintColor:[UIColor blackColor]];
        [self addSubview:_titleLabel];
        [_titleLabel setTextAlignment:NSTextAlignmentCenter];
        
        self.detailLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        [_detailLabel setTintColor:[UIColor blackColor]];
        [_detailLabel setFont:[UIFont systemFontOfSize:12]];
        [_detailLabel setTextAlignment:NSTextAlignmentCenter];
        [_detailLabel setNumberOfLines:0];
        [_detailLabel sizeToFit];
        [self addSubview:_detailLabel];
        
        self.image = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
        [self addSubview:_image];
        
        [_image setBackgroundColor:[UIColor blueColor]];
        [_titleLabel setBackgroundColor:[UIColor redColor]];
        
        [_detailLabel setBackgroundColor:[UIColor yellowColor]];

        
    }
    
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    [_image setFrame:CGRectMake(10, 0, self.frame.size.width / 3, self.frame.size.height)];
    [_titleLabel setFrame:CGRectMake(_image.frame.size.width + 20, self.frame.size.height / 4, self.frame.size.width / 3 * 2 - 30, self.frame.size.height / 4)];
    [_detailLabel setFrame:CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 20, self.frame.size.width / 3 * 2 - 30, self.frame.size.height / 4)];
}

#pragma mark - 监听model
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
    }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
